﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TabControlAdapter.cs" company="">
//   
// </copyright>
// <summary>
//   The tab control adapter.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Libium.Adapters
{
    using System.Windows.Forms;

    using Libium.Views;

    // TODO Remove or think about dynamic view creation...
    /// <summary>
    /// The tab control adapter.
    /// </summary>
    public class TabControlAdapter : ControlAdapter<TabControl>, IItemsView
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="TabControlAdapter"/> class.
        /// </summary>
        /// <param name="control">
        /// The control.
        /// </param>
        public TabControlAdapter(TabControl control)
            : base(control)
        {
        }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The add item view.
        /// </summary>
        /// <param name="typeName">
        /// The type name.
        /// </param>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        public object AddItemView(string typeName)
        {
            var page = new TabPage();
            Control.TabPages.Add(page);
            return page;
        }

        /// <summary>
        /// The clear.
        /// </summary>
        public override void Clear()
        {
            Control.TabPages.Clear();
        }

        /// <summary>
        /// The delete item view.
        /// </summary>
        /// <param name="view">
        /// The view.
        /// </param>
        public void DeleteItemView(object view)
        {
            Control.TabPages.Remove((TabPage)view);
        }

        #endregion
    }
}